Skip to content

Support simulation from scratch when model has no dataset#52

Open
roninsightrx wants to merge 1 commit intomainfrom
no-data-sim
Open

Support simulation from scratch when model has no dataset#52
roninsightrx wants to merge 1 commit intomainfrom
no-data-sim

Conversation

@roninsightrx
Copy link
Copy Markdown
Contributor

Summary

  • create_sim_dataset(): when model$dataset is NULL (i.e. the $DATA file can't be found) and no data argument is supplied, build the simulation dataset from scratch if regimen is provided — otherwise error with a clear message. Uses a placeholder-marker approach to carry covariate values into dose rows via fill() without leaving ghost rows in the output.
  • create_sim_dataset(): fix covariate column retention — when sim_data has no pre-existing covariate columns (from-scratch case), union(sim_data_cols, all_cov_cols) ensures newly-joined columns survive the select().
  • run_sim(): abort with a clear message when model$dataset is NULL and data = NULL.
  • run_sim(): validate required columns via get_required_input_variables() before running, giving an actionable error (naming the missing columns) when the dataset is incomplete.

Test plan

  • create_sim_dataset(no-data): error when no dataset and no regimen
  • create_sim_dataset(no-data): regimen-only produces correct dose + obs structure
  • create_sim_dataset(no-data): n_subjects defaults to 1, or from nrow(covariates)
  • create_sim_dataset(no-data): covariates are applied correctly and appear in output
  • create_sim_dataset(no-data): no .placeholder column leaks into output
  • run_sim(): data = NULL falls back to model$dataset (existing model with real data)
  • run_sim(): clear error when model$dataset is NULL and data = NULL
  • run_sim(): clear error naming the missing column when required column absent from dataset
  • Existing tests unaffected (from-scratch path only triggers when model$dataset is NULL)

🤖 Generated with Claude Code

… validation

- create_sim_dataset(): when model$dataset is NULL and no data arg is supplied,
  build the simulation dataset from scratch if regimen is provided. Uses a
  placeholder-marker approach to carry covariate values into dose rows via fill()
  without leaving ghost rows in the output.
- create_sim_dataset(): fix covariate join so newly-joined columns are retained
  when sim_data has no pre-existing covariate columns (union sim_data_cols with
  all_cov_cols before the select()).
- run_sim(): abort with a clear message when model$dataset is NULL and data=NULL.
- run_sim(): validate required columns via get_required_input_variables() before
  running, giving an actionable error when columns are missing.
- Tests for all new paths in test-create_sim_dataset.R and test-run_sim.R.
- Bump version to 0.0.0.9029.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant